// pages/own/own.js
import {
  OwnModel
} from '../../model/own'
import {
  config
} from '../../config'
var own = new OwnModel()
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    height:0,
    info: {},
    LabelList: [{
        icon: '/static/order.png',
        title: '订单中心',
        url: '/pages/orderCenter/orderCenter'
      },
      {
        icon: '/static/wallet.png',
        title: '我的钱包',
        url: '/pages/wallet/wallet'
      },
      {
        icon: '/static/fans.png',
        title: '我的花粉',
        url: '/pages/visitor/visit/visit'
      },
    ],
    itemList: [{
        icon: '/static/cart.png',
        title: "购物车",
        url: "/pages/cart/list/list"
      },
      {
        icon: '/static/course.png',
        title: "我的课程",
        url: ""
      },
      {
        icon: '/static/address2.png',
        title: "收货地址",
        url: "/pages/address/list/list"
      },
      // {
      //   icon: '/static/coupon.png',
      //   title: "风尚盛典礼券",
      //   url: "/pages/certificate/certificate"
      // },
    ],
    isConfirmOrder: 0,
    q: [{
      icon: '/static/icon_qianbao.png.png',
      title: '我的钱包',
      label: '佣金可提现',
      url: '/pages/wallet/wallet'
    }, {
      icon: '/static/icon_huafeng.png.png',
      title: '我的花粉',
      label: '访客购买统计',
      url: '/pages/visitor/visit/visit'
    }],
    o: [{
      icon: '/static/icon_wodedingdan.png.png',
      title: '我的订单',
      url: '/pages/orderCenter/orderCenter?picked=0'
    }, {
      icon: '/static/icon_daifukuan.png.png',
      title: '待付款',
      url: '/pages/orderCenter/orderCenter?picked=1'
    }, {
      icon: '/static/icon_daifahuo.png.png',
      title: '待发货',
      url: '/pages/orderCenter/orderCenter?picked=2'
    }, {
      icon: '/static/icon_dishouhuo.png.png',
      title: '待收货',
      url: '/pages/orderCenter/orderCenter?picked=3'
    }, {
      icon: '/static/icon_tuikuan.png.png',
      title: '退款/售后',
      url: '/pages/orderCenter/orderCenter?picked=4'
    }, ],
    s: [{
      icon: '/static/icon_gouwuche.png.png',
      title: '购物车',
      url: "/pages/cart/list/list"
    }, {
      icon: '/static/icon_wodekecheng.png.png',
      title: '我的课程',
      url: ""
    }, {
      icon: '/static/icon_dizhiguanli.png.png',
      title: '地址管理',
      url: "/pages/address/list/list"
    }, 
    {
      icon: '/static/icon_dingdanluru.png.png',
      title: '定制订单',
      url:'/pages/customOrder/list/list'
    },{
      icon: '/static/icon_dingdanbangding.png.png',
      title: '订单绑定 ',
      url:'/pages/order/bindOrder/bindOrder'
    }, ],
    w: [{
      icon: '/static/icon_dingdlur.png.png',
      title: '订单录入',
      url: "/pages/order/input/input"
    }, {
      icon: '/static/icon_guanlizhongxing.png.png',
      title: '管理中心',
      url: "/pages/managementCenter/managementCenter"
    }, {
      icon: '',
      title: ''
    }, {
      icon: '',
      title: ''
    }, ]
  },
  toOrder() {
    wx.navigateTo({
      url: '/pages/order/isConfirmOrder/isConfirmOrder',
    })
  },
  boundPhone() {
    wx.navigateTo({
      url: '/pages/login/login',
    })
  },

  getInfo() {
    own.info().then(
      res => {
        // debugger;
        if (res.code === 0) {
          res.data.isMobile = config.isMobile
          this.setData({
            info: res.data
          })
          // app.globalData.userInfo.nickName = res.data.nickName
          // app.globalData.userInfo.avatarUrl = res.data.picture
        }
      }
    )
  },

  vipAction() {
    wx.navigateTo({
      url: '/pages/vip/vip',
    })
  },

  itemAction: function (e) {
    if (config.isMobile != "1") {
      wx.showToast({
        title: '请绑定手机号',
        icon: 'none'
      })
      return
    }
    var data = e.currentTarget.dataset
    if (data.item.url) {
      wx.navigateTo({
        url: data.item.url,
      })
    } else {
      wx.showToast({
        title: '此功能开发中',
        icon: 'none'
      })
    }
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getSystemInfo({
      success(res) {
        console.log(res)
        that.setData({
          height:res.screenHeight
        })
      }
    })
    this.setData({
      isConfirmOrder: app.globalData.userInfo.isConfirmOrder
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getInfo()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})